﻿@{
    ViewData["Title"] = "Index";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{
    <script type="text/javascript">
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            treetable: 'treetable-lay/treetable',
            index: 'lib/index'
        }).use(['table', 'form', 'treetable', 'index', 'laydate'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , table = layui.table
                , element = layui.element
                , laydate = layui.laydate
                , treetable = layui.treetable;
            top.SetListPageLanguage(layui);

            //日期范围
            laydate.render({
                elem: '#timeSetup'
                , range: true
            });

            $.getJSON("/Reports/GetEnOrderType", function (result) {
                let plat = result.data;
                $('#enOrderType').append(new Option(top.lang.pleaseSelect, ""));
                plat.forEach(function (v) {
                    $('#enOrderType').append(new Option(v, v));
                });
                layui.form.render("select");
            });

            $.getJSON("/Reports/GetOrderSymbol", function (result) {
                let plat = result.data;
                $('#symbol').append(new Option(top.lang.pleaseSelect, ""));
                plat.forEach(function (v) {
                    $('#symbol').append(new Option(v, v));
                });
                layui.form.render("select");
            });

            // 渲染表格
            orderTable = function () {
                table.render({
                    elem: '#datalist'
                    , url: '/Reports/GetOrderList'
                    , limit: 20
                    , title: '入金审核'
                    , cols: [[
                        { field: 'orderNumber', title: '订单号', width: 100 }
                        //, { field: 'tradingAccountNo', title: '交易账号', width: 100 }

                        //, { field: 'externalId', title: 'ID' }
                        , { field: 'symbol', title: '交易品种', width: 100 }
                        , {
                            field: 'timeSetup', title: '时间', templet: function (res) {
                                if (res.timeSetup <= 0) {
                                    return ""
                                }
                                else {
                                    return formatTime(res.timeSetup, 'Y-M-D h:m:s')
                                }
                            }
                        }
                        , { field: 'enOrderType', title: '类型' }
                        , { field: 'volume', title: '交易量', width: 120 }
                        , { field: 'priceCurrent', title: '当前价格',width: 120 }
                        //, { field: 'priceOrder', title: '价格',width: 120  }
                        , { field: 'priceSl', title: '止损', width: 120 }
                        , { field: 'priceTp', title: '止盈', width: 120 }
                      
                        , {
                            field: 'timeExpiration', title: '到期', templet: function (res) {
                                if (res.timeExpiration <= 0) {
                                    return ""
                                }
                                else {
                                    return formatTime(res.timeExpiration, 'Y-M-D h:m:s')
                                }
                            }
                        }
                    ]]
                    , id: "datalist"
                    , defaultToolbar: false
                    , page: { layout: ['prev', 'page', 'next', 'refresh'] }
                    , done: function (res) {
                        if (res.count == 0) {
                            $(".layui-table-main").html('<div class="layui-none">' + top.lang.noData + '</div>');
                        }
                        layer.closeAll('loading');
                        /**多语言初始化 */
                        top.SetListPageLanguage(layui);
                        layui.form.render("select");
                    }
                });
            };
            orderTable();
            //查询
            form.on('submit(search)', function (data) {
                //执行重载
                table.reload('datalist', {
                    page: { curr: 1, layout: ['prev', 'page', 'next', 'refresh'] }
                    , where: {
                        order: $("#orderNumber").val(),
                        type: $("#enOrderType  option:selected").val(),
                        symbol: $("#symbol option:selected").val(),
                        time: $("#timeSetup").val()
                    }
                });
            });

            //重置
            form.on('submit(resetting)', function (data) {
                    $("#orderNumber").val(''),
                    $("#enOrderType").val(''),
                    $("#symbol").val(''),
                    $("#timeSetup").val('')
                //执行重载
                table.reload('datalist', {
                    page: { curr: 1, layout: ['prev', 'page', 'next', 'refresh'] }
                    , where: {
                        order: "",
                        type: "",
                        symbol: "",
                        time: "",
                    }
                });
            });


        });
    </script>
}
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card" lay-filter="component-form-element">
                    <div class="layui-card-body layui-form layui-form-pane" style="padding: 15px;">
                        <div class="layui-form-item">
                            <div class="layui-form-item">
                                <blockquote class="layui-elem-quote" lay-event="tips">此页面的数据会有稍许延时，最新数据请在MT5端进行获取查询</blockquote>
                                <div class="layui-inline">
                                    <label class="layui-form-label" lay-event="orderNumber">订单号</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="orderNumber" name="orderNumber" placeholder="orderNumber" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" lay-event="orderState">类型</label>
                                    <div class="layui-input-inline">
                                        <select name="enOrderType" id="enOrderType">
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" lay-event="symbol">交易品种</label>
                                    <div class="layui-input-inline">
                                        <select name="symbol" id="symbol">
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" lay-event="timeSetup">时间</label>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" id="timeSetup" name="timeSetup" placeholder="timeSetup" lay-key="8">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <button class="layui-btn" lay-submit lay-filter="search" lay-event="search">搜索</button>
                                    <button class="layui-btn layui-btn-primary" lay-submit lay-filter="resetting" lay-event="resetting">重置</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-card">
                    <div class="layui-card-body">
                        <div class="layui-tab-content" style="padding:0;">
                            <table class="layui-hide" id="datalist" lay-filter="datalist"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>